package 集合;

import 树.BinarySearchTree;
import 集合.接口.Set;

import java.util.Iterator;

public class TreeSet<E extends Comparable<E>> implements Set<E> {

    private BinarySearchTree<E> tree;

    public TreeSet(){
        tree = new BinarySearchTree<E>();
    }

    @Override
    public void add(E e) {
        tree.add(e);
    }

    public E removeMin(){
        return tree.removeMin();
    }

    @Override
    public boolean contains(E e) {
        return tree.contains(e);
    }

    @Override
    public void remove(E e) {
        tree.remove(e);
    }

    @Override
    public int size() {
        return tree.size();
    }

    @Override
    public boolean isEmpty() {
        return tree.isEmpty();
    }

    @Override
    public void clear() {
        tree.clear();
    }

    @Override
    public Iterator<E> iterator() {
        return tree.iterator();
    }
}
